#include<iostream>
#include<vector>
#include<stack>
using namespace std;
class Solution {
public:
    bool validateStackSequences(vector<int>& pushed, vector<int>& popped) {
        int i = 0;
        int j = 0;
        while (i < static_cast<int>(pushed.size()))
        {
            st.push(pushed[i]);
            while (j < static_cast<int>(popped.size()) && !st.empty() && st.top() == popped[j])
            {
                st.pop();
                ++j;
            }
            ++i;
        }
        if (j == static_cast<int>(popped.size()))
            return true;
        return false;
    }
private:
    stack<int> st;
};
int main()
{
    vector<int> pushnums = { 0 , 1 };
    vector<int> popnums = { 0, 1 };
    cout << Solution().validateStackSequences(pushnums, popnums) << endl;
    return 0;
}